<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">



  
  
    
    
  <script src="/dxl/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/dxl/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/dxl/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/dxl/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/dxl/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/dxl/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/dxl/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/dxl/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/dxl/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="面试题,">










<meta name="description" content="第五章 python的底层网络交互模块有哪些？  1socket，urllib，requests，pycurl   简述 OSI 七层协议。   12345678#有低到高的排序物理层：主要是基于电器特性发送高低电压（电信号），高电压对应数字1，低电压对应数字0数据链路层：定义了电信号的分组方式网路层：引入一套新的地址用来区分不同的广播域/子网，这套地址即网络地址传输层：建立端口到端口的通信会话层">
<meta name="keywords" content="面试题">
<meta property="og:type" content="article">
<meta property="og:title" content="绿皮书02">
<meta property="og:url" content="http://yoursite.com/2019/09/20/【面试题】01-2绿皮书二/index.html">
<meta property="og:site_name" content="我的快乐时光">
<meta property="og:description" content="第五章 python的底层网络交互模块有哪些？  1socket，urllib，requests，pycurl   简述 OSI 七层协议。   12345678#有低到高的排序物理层：主要是基于电器特性发送高低电压（电信号），高电压对应数字1，低电压对应数字0数据链路层：定义了电信号的分组方式网路层：引入一套新的地址用来区分不同的广播域/子网，这套地址即网络地址传输层：建立端口到端口的通信会话层">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://yoursite.com/2019/09/%E5%8D%9A%E5%AE%A2/%E5%86%85%E5%AE%B9%E5%9B%9E%E9%A1%BE/assets/1566788049755.png">
<meta property="og:updated_time" content="2019-09-20T12:06:45.144Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="绿皮书02">
<meta name="twitter:description" content="第五章 python的底层网络交互模块有哪些？  1socket，urllib，requests，pycurl   简述 OSI 七层协议。   12345678#有低到高的排序物理层：主要是基于电器特性发送高低电压（电信号），高电压对应数字1，低电压对应数字0数据链路层：定义了电信号的分组方式网路层：引入一套新的地址用来区分不同的广播域/子网，这套地址即网络地址传输层：建立端口到端口的通信会话层">
<meta name="twitter:image" content="http://yoursite.com/2019/09/%E5%8D%9A%E5%AE%A2/%E5%86%85%E5%AE%B9%E5%9B%9E%E9%A1%BE/assets/1566788049755.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/dxl/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":true,"scrollpercent":true,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2019/09/20/【面试题】01-2绿皮书二/">





  <title>绿皮书02 | 我的快乐时光</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/dxl/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">我的快乐时光</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/dxl/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/dxl/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/dxl/2019/09/20/【面试题】01-2绿皮书二/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content>
      <meta itemprop="description" content>
      <meta itemprop="image" content="/dxl/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="我的快乐时光">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">绿皮书02</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-09-20T20:05:12+08:00">
                2019-09-20
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/dxl/categories/面试题/" itemprop="url" rel="index">
                    <span itemprop="name">面试题</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/dxl/2019/09/20/【面试题】01-2绿皮书二/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/dxl/2019/09/20/【面试题】01-2绿皮书二/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv">本文总阅读量
            <span class="busuanzi-value" id="busuanzi_value_page_pv"></span>次
            </span>
          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="第五章"><a href="#第五章" class="headerlink" title="第五章"></a>第五章</h2><ol>
<li>python的底层网络交互模块有哪些？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">socket，urllib，requests，pycurl</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>简述 OSI 七层协议。</li>
</ol>
<p><img src="../../%E5%8D%9A%E5%AE%A2/%E5%86%85%E5%AE%B9%E5%9B%9E%E9%A1%BE/assets/1566788049755.png" alt="1566788049755"></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#有低到高的排序</span></span><br><span class="line">物理层：主要是基于电器特性发送高低电压（电信号），高电压对应数字<span class="number">1</span>，低电压对应数字<span class="number">0</span></span><br><span class="line">数据链路层：定义了电信号的分组方式</span><br><span class="line">网路层：引入一套新的地址用来区分不同的广播域/子网，这套地址即网络地址</span><br><span class="line">传输层：建立端口到端口的通信</span><br><span class="line">会话层：建立客户端与服务端连接</span><br><span class="line">表示层：对来自应用层的命令和数据进行解释，按照一定格式传给会话层。如编码、数据格式转换、加密解密、压缩解压</span><br><span class="line">应用层：规定应用程序的数据格式</span><br></pre></td></tr></table></figure>

<p>每一层协议的物理设备及地址</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">简化版五层协议：</span><br><span class="line">    应用层  python   send(b&apos;hello,world&apos;)</span><br><span class="line">    socket</span><br><span class="line">    传输层   端口 tcp/udp协议   四层路由器  四层交换机</span><br><span class="line">    网络层   ip地址相关 ip协议  路由器  三层交换机</span><br><span class="line">    数据链路层  mac地址相关 arp协议   网卡 二层交换机</span><br><span class="line">    物理层   网线</span><br></pre></td></tr></table></figure>

<ol start="3">
<li><p>什么是C/S和B/S架构？</p>
 <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">C/S :client(客户端)  server(服务端)</span><br><span class="line">    B/S :browser(浏览器) server(服务端)</span><br><span class="line">    C/S：安装一个客户端，然后客户端可以和服务端进行网络进行交互。</span><br><span class="line">    B/S：所有能够用网页访问的网站 这个网站是B/S架构的。</span><br><span class="line">    B/S和C/S架构的关系：</span><br><span class="line">        所有的B/S架构都需要一个浏览器才能访问</span><br><span class="line">        浏览器是一个软件,相当于一个客户端</span><br><span class="line">        所有的B/S架构也都是C/S架构的</span><br><span class="line">        浏览器(browser)是特殊的客户端(client)</span><br><span class="line">        client(broser) &lt;---&gt; server</span><br><span class="line">    优越点：</span><br><span class="line">    C/S：</span><br><span class="line">    C/S 装好之后直接双击就可以使用了</span><br><span class="line">    B/S：</span><br><span class="line">        极大的简化了我们使用软件的成本</span><br><span class="line">        更符合现在的使用理念</span><br><span class="line">        但是还有很多功能没有实现</span><br><span class="line">        在PC端统一了程序的入口</span><br></pre></td></tr></table></figure>
</li>
<li><p>简述 TCP 三次握手、四次挥手的流程</p>
 <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">三次握手</span><br><span class="line">	第一次握手：客户端的应用进程主动打开，并向客户端发出请求报文段。其首部中：SYN=<span class="number">1</span>,seq=x。</span><br><span class="line">	第二次握手：服务器应用进程被动打开。若同意客户端的请求，则发回确认报文，其首部中：			SYN=<span class="number">1</span>,ACK=<span class="number">1</span>,ack=x+<span class="number">1</span>,seq=y。</span><br><span class="line">	第三次握手：客户端收到确认报文之后，通知上层应用进程连接已建立，并向服务器发出确认报文，其首部：ACK=<span class="number">1</span>,ack=y+<span class="number">1</span>。当服务器收到客户端的确认报文之后，也通知其上层应用进程连接已建立。</span><br><span class="line">四次挥手</span><br><span class="line">	第一次挥手：数据传输结束以后，客户端的应用进程发出连接释放报文段，并停止发送数据，其首部：FIN=<span class="number">1</span>,seq=u。</span><br><span class="line">	服务器端收到连接释放报文段之后，发出确认报文，其首部：ack=u+<span class="number">1</span>,seq=v。此时本次连接就进入了半关闭状态，客户端不再向服务器发送数据。而服务器端仍会继续发送。</span><br><span class="line">	第三次挥手：若服务器已经没有要向客户端发送的数据，其应用进程就通知服务器释放TCP连接。这个阶段服务器所发出的最后一个报文的首部应为：FIN=<span class="number">1</span>,ACK=<span class="number">1</span>,seq=w,ack=u+<span class="number">1</span>。</span><br><span class="line">	第四次挥手：客户端收到连接释放报文段之后，必须发出确认：ACK=<span class="number">1</span>,seq=u+<span class="number">1</span>,ack=w+<span class="number">1</span>。 再经过<span class="number">2</span>MSL(最长报文端寿命)后，本次TCP连接真正结束，通信双方完成了他们的告别。</span><br></pre></td></tr></table></figure>
</li>
<li><p>什么是arp协议？</p>
 <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ARP（Address Resolution Protocol），地址解析协议，是根据IP地址获取主机地址的一个协议。</span><br></pre></td></tr></table></figure>
</li>
<li><p>TCP和UDP的区别？为何基于tcp协议的通信比基于udp协议的通信更可靠？</p>
 <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">TCP---传输控制协议,提供的是面向连接、可靠的字节流服务。当客户和服务器彼此交换数据前，必须先在双方之间建立一个TCP连接，之后才能传输数据。TCP提供超时重发，丢弃重复数据，检验数据，流量控制等功能，保证数据能从一端传到另一端。 </span><br><span class="line">UDP---用户数据报协议，是一个简单的面向数据报的运输层协议。UDP不提供可靠性，它只是把应用程序传给IP层的数据报发送出去，但是并不能保证它们能到达目的地。由于UDP在传输数据报前不用在客户和服务器之间建立一个连接，且没有超时重发等机制，故而传输速度很快</span><br></pre></td></tr></table></figure>
</li>
<li><p>什么是局域网和广域网？</p>
 <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">    　局域网（Local Area Network，LAN）是指在某一区域内由多台计算机互联成的计算机组</span><br><span class="line">    　广域网。是连接不同地区局域网或城域网计算机通信的远程网。通常跨接很大的物理范围，所覆盖的范围从几十公里到几千公里，它能连接多个地区、城市和国家，或横跨几个洲并能提供远距离通信，形成国际性的远程网络。广域网并不等同于互联网。</span><br></pre></td></tr></table></figure>
</li>
<li><p>什么是socket？简述基于tcp协议的套接字通信流程。</p>
 <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">Socket是应用层与TCP/IP协议族通信的中间软件抽象层，它是一组接口。</span><br><span class="line">在设计模式中，Socket其实就是一个门面模式，它把复杂的TCP/IP协议族隐藏在Socket接口后面，</span><br><span class="line">对用户来说，一组简单的接口就是全部。</span><br><span class="line"><span class="comment">#过程</span></span><br><span class="line">    服务端创建一个ServerSocket对象,指定端口号,ServerSocket对象等待客户端的连接请求。</span><br><span class="line">    客户端创建一个Socket对象,指定主机地址和端口号,向服务端发出连接请求。</span><br><span class="line">    服务端接收到客户端的连接请求,建立一条TCP连接,再创建一个Socket对象与客户端的Socket对象进行通信。</span><br><span class="line">    服务端和客户端分别创建字节输入流和字节输出流,通过字节输入流获得对方发来的数据,通过字节输出流向对方发送数据。</span><br><span class="line">    当一方决定结束通信时,向对方发送结束信息;另一方接收到结束信息后,双方分别关闭各自的TCP连接。</span><br><span class="line">    ServerSocket对象停止等待客户端的连接请求。</span><br></pre></td></tr></table></figure>
</li>
<li><p>什么是粘包？ socket 中造成粘包的原因是什么？ 哪些情况会发生粘包现象？</p>
 <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">只有TCP有粘包现象，UDP永远不会粘包</span><br><span class="line">粘包：在获取数据时,出现数据的内容不是本应该接收的数据,如:对方第一次发送hello,第二次发送world,</span><br><span class="line">　　我方接收时,应该收两次,一次是hello,一次是world,但事实上是一次收到helloworld,一次收到空,这种现象叫粘包</span><br><span class="line"></span><br><span class="line">原因</span><br><span class="line">	粘包问题主要还是因为接收方不知道消息之间的界限，不知道一次性提取多少字节的数据所造成的。</span><br><span class="line"></span><br><span class="line">什么情况会发生：</span><br><span class="line">	1、发送端需要等缓冲区满才发送出去，造成粘包（发送数据时间间隔很短，数据了很小，会合到一起，产生粘包）</span><br><span class="line">	2、接收方不及时接收缓冲区的包，造成多个包接收（客户端发送了一段数据，服务端只收了一小部分，</span><br><span class="line">服务端下次再收的时候还是从缓冲区拿上次遗留的数据，产生粘包）</span><br></pre></td></tr></table></figure>



</li>
</ol>
<ol start="10">
<li><p>IO多路复用的作用？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">socketserver，多个客户端连接，单线程下实现并发效果，就叫多路复用。</span><br><span class="line">与多进程和多线程技术相比，I/O多路复用技术的最大优势是系统开销小，系统不必创建进程/线程，也不必维护这些进程/线程，从而大大减小了系统的开销。</span><br></pre></td></tr></table></figure>



</li>
</ol>
<ol start="11">
<li><p>什么是防火墙以及作用？</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">什么是防火墙：	</span><br><span class="line">	防火墙是一个分离器、一个限制器，也是一个分析器，有效地监控了内部网和Internet之间的任何活动，保证了内部网络的安全</span><br><span class="line">作用：</span><br><span class="line">    防火墙是网络安全的屏障</span><br><span class="line">    可以强化网络安全策略</span><br><span class="line">    对网络存取和访问进行监控审计</span><br><span class="line">    防止内部信息的外泄</span><br><span class="line">    除了安全作用，防火墙还支持具有Internet服务特性的企业内部网络技术体系VPN（虚拟专用网）。</span><br></pre></td></tr></table></figure>
</li>
<li><p>select、poll、epoll 模型的区别？</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">支持一个进程所能打开的最大连接数</span><br><span class="line">	select的最大连接数大概<span class="number">3232</span>，或者<span class="number">3264</span></span><br><span class="line">	poll本质和select没区别，但是它没有最大连接数限制</span><br><span class="line">	epoll大概<span class="number">10</span>万左右(<span class="number">1</span>G的机器)</span><br><span class="line">FD剧增后带来的IO效率问题</span><br><span class="line">	select和poll每次调用都会对连接进行线性遍历，所以会随着FD的增加会造成遍历速度慢的“线性下降性能问题”</span><br><span class="line">	epoll没有前两个的线性下降的性能问题，但是当socket都很活跃的情况下，可能会有性能问题。</span><br><span class="line">消息传递方式</span><br><span class="line">	select和poll内核需要将消息传递到用户空间，都需要内核拷贝动作。</span><br><span class="line">	epoll通过内核和用户空间共享一块内存来实现</span><br></pre></td></tr></table></figure>
</li>
<li><p>简述 进程、线程、协程的区别 以及应用场景？</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 进程</span></span><br><span class="line">    <span class="comment"># 特点：操作系统级别 开销大 数据隔离</span></span><br><span class="line">         <span class="comment"># 资源分配的最小单位 数据不安全</span></span><br><span class="line">         <span class="comment"># 可以利用多核</span></span><br><span class="line"><span class="comment"># 线程</span></span><br><span class="line">    <span class="comment"># 特点：操作系统级别 开销小 数据共享</span></span><br><span class="line">         <span class="comment"># 被cpu调度的最小单位 数据不安全</span></span><br><span class="line">         <span class="comment"># 可以利用多核</span></span><br><span class="line"><span class="comment"># 协程</span></span><br><span class="line">    <span class="comment"># 特点：用户级别  开销极小 数据共享的</span></span><br><span class="line">        <span class="comment"># 不能利用多核 从代码级别来看数据安全</span></span><br><span class="line">应用场景</span><br><span class="line">	协程：当程序中存在大量不需要cpu的操作时，适用协程</span><br><span class="line">	计算密集型，用进程。IO密集型，用线程。</span><br></pre></td></tr></table></figure>



</li>
</ol>
<ol start="14">
<li><p>什么是GIL锁？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">全局解释器锁，保证了同意时刻同意进程之内只有一个线程可以反问cpu</span><br></pre></td></tr></table></figure>
</li>
<li><p>Python中如何使用线程池和进程池？</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">进程池的开启</span><br><span class="line"><span class="number">1</span>、导包</span><br><span class="line">	<span class="keyword">from</span> concurrent.futures <span class="keyword">import</span>  ProcessPoolExecutor,ThreadPoolExecutor</span><br><span class="line"><span class="number">2</span>、开启线程池</span><br><span class="line">    <span class="keyword">if</span> __name__ ==<span class="string">'__main__'</span>:</span><br><span class="line">        p = ProcessPoolExecutor(<span class="number">4</span>)</span><br><span class="line"><span class="number">3</span>、准备要异步执行的函数</span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">make</span><span class="params">(i)</span>:</span></span><br><span class="line">        time.sleep(random.uniform(<span class="number">1</span>,<span class="number">3</span>))</span><br><span class="line">        print(<span class="string">f'您好<span class="subst">&#123;i&#125;</span>'</span>,os.getpid())</span><br><span class="line">        <span class="keyword">return</span> i</span><br><span class="line">     <span class="function"><span class="keyword">def</span> <span class="title">call_back</span><span class="params">(arg)</span>:</span></span><br><span class="line">    	print(arg.result())</span><br><span class="line"><span class="number">3</span>、提交异步任务</span><br><span class="line">	<span class="keyword">for</span> i <span class="keyword">in</span> range(<span class="number">10</span>):</span><br><span class="line">        ret = p.submit(make,i)</span><br><span class="line">        ret.add_done_callback(call_back)<span class="comment">#执行回调函数</span></span><br><span class="line"> </span><br><span class="line"> 进程池的开启与进程池差不多就是导入得包不一样</span><br></pre></td></tr></table></figure>
</li>
<li><p>threading.local的作用？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">为每个线程创建一个独立的空间，使得线程对自己的空间中的数据进行操作(数据隔离)。</span><br></pre></td></tr></table></figure>
</li>
<li><p>进程之间如何进行通信？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">1、创建共享队列</span><br><span class="line">2、Manager实现数据共享</span><br><span class="line">3、通过piple管道</span><br><span class="line">4、socket</span><br></pre></td></tr></table></figure>
</li>
<li><p>什么是并发和并行？</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 并发：同一时刻只能处理一个任务，但一个时段内可以对多个任务进行交替处理(一个处理器同时处理多个任务)</span></span><br><span class="line"><span class="comment"># 并行：同一时刻可以处理多个任务(多个处理器或者是多核的处理器同时处理多个不同的任务)</span></span><br><span class="line"><span class="comment"># 类比：并发是一个人同时吃三个馒头，而并行是三个人同时吃三个馒头。</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>解释什么是异步非阻塞？</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#</span></span><br><span class="line">非阻塞：不等待</span><br><span class="line">	即：遇到IO阻塞不等待(setblooking=False),（可能会报错-&gt;捕捉异常）</span><br><span class="line">异步：回调，当达到某个指定的状态之后，自动调用特定函数</span><br><span class="line">实例</span><br><span class="line">nb_async.py   实现异步非阻塞的模块</span><br></pre></td></tr></table></figure>
</li>
<li><p>路由器和交换机的区别？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">1：交换机：是负责内网里面的数据传递（arp协议）根据MAC地址寻址</span><br><span class="line">   路由器：在网络层，路由器根据路由表，寻找该ip的网段</span><br><span class="line">2：路由器可以处理TCP/IP协议</span><br><span class="line">3：路由器可以把一个IP分配给很多个主机使用，这些主机对外只表现出一个IP。</span><br><span class="line">   交换机可以把很多主机连起来，这些主机对外各有各的IP。</span><br><span class="line">4：交换机是做端口扩展的，也就是让局域网可以连进来更多的电脑。</span><br><span class="line">  路由器是用来做网络连接，也就是；连接不同的网络</span><br></pre></td></tr></table></figure>
</li>
<li><p>什么是域名解析？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">域名解析就是将域名，转换为ip地址的这样一种行为。</span><br><span class="line">出现原因：IP地址不好记，域名好记</span><br></pre></td></tr></table></figure>
</li>
<li><p>如何修改本地hosts文件？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">1.找到目录下的hosts文件:</span><br><span class="line">C:\Windows\System32\drivers\etc\hosts</span><br><span class="line">2、打开文件进行修改</span><br></pre></td></tr></table></figure>
</li>
<li><p>生产者消费者模型应用场景？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">并发进程，和并发线程，爬虫</span><br></pre></td></tr></table></figure>
</li>
<li><p>什么是cdn？</p>
</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">CDN的全称是Content Delivery Network，即内容分发网络。CDN是构建在现有网络基础之上的智能虚拟网络，依靠部署在各地的边缘服务器，通过中心平台的负载均衡、内容分发、调度等功能模块，使用户就近获取所需内容，降低网络拥塞，提高用户访问响应速度和命中率。CDN的关键技术主要有内容存储和分发技术。</span><br></pre></td></tr></table></figure>

<p>25、程序从Flag A执行到Flag B的时间大致为多少秒</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">import threading</span><br><span class="line">import time</span><br><span class="line">def _wait():</span><br><span class="line">    time.sleep(60)</span><br><span class="line">start = time.time()</span><br><span class="line"></span><br><span class="line">t = threading.Thread(target=_wait, daemon=False)</span><br><span class="line">t.start()</span><br><span class="line">end =time.time()</span><br><span class="line">print(end- start)  #秒</span><br></pre></td></tr></table></figure>

<p>26、 有A.txt和B.txt 两个文件, 使用多进程和进程池的方式分别读取这两个文件</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>27、以下那些是常见的TCP Flags?(多选)</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ACK,SYN</span><br></pre></td></tr></table></figure>

<p>28、下面关于网络七层和四层的描述,那条是错误的?</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">A.  SNMP工作在四层  <span class="comment">#第七层</span></span><br><span class="line">B.  四层是指网络的传输层, 主要包括IP和端口信息</span><br><span class="line">C.  七层是指网络的应用层(协议层), 比如http协议就工作在七层</span><br><span class="line">D.  四层主要应用于TCP和UDP的代理, 七层主要应用于HTTP等协议的代理</span><br></pre></td></tr></table></figure>

<p>29、racerroute 一般使用的是那种网络层协议</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">traceroute他是一个用于追踪数据包路径的工具。它使用了网络层中的ICMP协议来实现。</span><br></pre></td></tr></table></figure>

<p>30、iptables知识考察, 根据要求写出防火墙规则?</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">A.  屏蔽<span class="number">192.168</span><span class="number">.1</span><span class="number">.5</span>访问本机dns服务端口</span><br><span class="line"></span><br><span class="line">B.  允许<span class="number">10.1</span><span class="number">.1</span><span class="number">.0</span>/<span class="number">24</span>访问本机的udp <span class="number">8888</span> <span class="number">9999</span>端口</span><br></pre></td></tr></table></figure>

<p>31、业务服务器192.168.1.2访问192.168.1.3数据接口, 无法正常返回数据, 请根据以上信息写出排查思路。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>32、请实现一个简单的socket编程, 要求：</p>
<ol>
<li><p>实现server端的功能即可</p>
</li>
<li><p>遵循基本语言编程规范</p>
 <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"> </span><br></pre></td></tr></table></figure>

</li>
</ol>
<p>33、谈一下对于多线程编程的理解, 对于CPU密集型怎样使用多线程, 说说线程池, 线程锁的用法, 有没有用过multiprocessing或concurrent.future？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>34、关于守护线程的说法, </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">主进程创建守护进程</span><br><span class="line">	守护进程会在主进程代码运行结束的情况下，立即挂掉。</span><br><span class="line">	守护进程本身就是一个子进程。</span><br><span class="line">	主进程在其代码结束后就已经算运行完毕了（守护进程在此时就被回收）,然后主进程会一直等非守护的子进程都运行完毕后回收子进程的资源(否则会产生僵尸进程)，才会结束，</span><br><span class="line">守护线程</span><br><span class="line">	守护线程会在&quot;该进程内所有非守护线程全部都运行完毕后,守护线程才会挂掉&quot;。并不是主线程运行完毕后守护线程挂掉。这一点是和守护进程的区别之处！</span><br><span class="line">	守护线程守护的是：当前进程内所有的子线程！</span><br><span class="line">	主线程在其他非守护线程运行完毕后才算运行完毕（守护线程在此时就被回收）。因为主线程的结束意味着进程的结束，进程整体的资源都将被回收，而进程必须保证非守护线程都运行完毕后才能结束。</span><br></pre></td></tr></table></figure>

<p>35、TCP协议在每次建立或者拆除连接时,都要在收发双方之间交换()报文</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">A.一个    B.两个</span><br><span class="line">C.三个    D.四个</span><br></pre></td></tr></table></figure>

<p>36、描述多进程开发中join与deamon的区别</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">join：当子线程调用join时，主线程会被阻塞，当子线程结束后，主线程才能继续执行。</span><br><span class="line">deamon：当子进程被设置为守护进程时，主进程结束，不管子进程是否执行完毕，都会随着主进程的结束而结束。</span><br></pre></td></tr></table></figure>

<p>37、请简述GIL对Python性能的影响</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">会降低多线程的效率。可以说python就是个单线程的程序</span><br><span class="line"><span class="comment">#如何避免：</span></span><br><span class="line">	使用多进程代替多线程</span><br><span class="line">    使用其他解释器</span><br></pre></td></tr></table></figure>

<p>38、曾经在哪里使用过：线程、进程、协程？</p>
<p>39、请使用yield实现一个协程？</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">consumer</span><span class="params">()</span>:</span></span><br><span class="line">    r = <span class="string">''</span></span><br><span class="line">    <span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">        n = <span class="keyword">yield</span> r</span><br><span class="line">        <span class="keyword">if</span> n <span class="keyword">is</span> <span class="literal">None</span>:</span><br><span class="line">            <span class="keyword">return</span></span><br><span class="line">        print(<span class="string">'[CONSUMER] Consuming %s...'</span> % n)</span><br><span class="line">        r = <span class="string">'200 OK'</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">produce</span><span class="params">(c)</span>:</span></span><br><span class="line">    c.send(<span class="literal">None</span>)</span><br><span class="line">    n = <span class="number">0</span></span><br><span class="line">    <span class="keyword">while</span> n &lt; <span class="number">5</span>:</span><br><span class="line">        n = n + <span class="number">1</span></span><br><span class="line">        print(<span class="string">'[PRODUCER] Producing %s...'</span> % n)</span><br><span class="line">        r = c.send(n)</span><br><span class="line">        print(<span class="string">'[PRODUCER] Consumer return: %s'</span> % r)</span><br><span class="line">    c.close()</span><br><span class="line"></span><br><span class="line">c = consumer()</span><br><span class="line">produce(c)</span><br></pre></td></tr></table></figure>

<p>40、请使用python内置async语法实现一个协程？</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> asyncio</span><br><span class="line"><span class="keyword">import</span> time</span><br><span class="line">now = <span class="keyword">lambda</span> : time.time()</span><br><span class="line"><span class="keyword">async</span> <span class="function"><span class="keyword">def</span> <span class="title">hello</span><span class="params">()</span>:</span></span><br><span class="line">    print(<span class="string">"hello"</span>)</span><br><span class="line">    <span class="keyword">await</span> asyncio.sleep(<span class="number">2</span>)</span><br><span class="line">    <span class="keyword">return</span> <span class="string">"done"</span></span><br><span class="line">    </span><br><span class="line">start = now()</span><br><span class="line"><span class="comment"># 协程对象</span></span><br><span class="line">h1 = hello()</span><br><span class="line">h2 = hello()</span><br><span class="line">h3 = hello()</span><br><span class="line"></span><br><span class="line"><span class="comment"># 创建一个事件loop</span></span><br><span class="line">loop = asyncio.get_event_loop()</span><br><span class="line"><span class="comment"># 任务（task）对象</span></span><br><span class="line">tasks = [</span><br><span class="line">asyncio.ensure_future(h1),</span><br><span class="line">asyncio.ensure_future(h2),</span><br><span class="line">asyncio.ensure_future(h3),</span><br><span class="line">]</span><br><span class="line"></span><br><span class="line"><span class="comment"># 将协程加入到事件循环loop</span></span><br><span class="line">loop.run_until_complete(asyncio.wait(tasks))</span><br><span class="line"><span class="keyword">for</span> task <span class="keyword">in</span> tasks:</span><br><span class="line">    print(task.result())</span><br><span class="line">    </span><br><span class="line">print(now()-start)</span><br></pre></td></tr></table></figure>

<p>41、简述线程死锁是如何造成的？如何避免？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">死锁的产生原因？</span><br><span class="line">	连续两次acquire</span><br><span class="line">	系统资源的竞争</span><br><span class="line">	进程运行推进顺序不当</span><br><span class="line">解决死锁</span><br><span class="line">	加锁顺序：线程按照一定的顺序加锁</span><br><span class="line">	加锁时限：线程尝试获取锁的时候加上一定的时限，超过时限，则放弃对该锁的请求，并释放自己占有的锁。</span><br><span class="line">	死锁检测</span><br></pre></td></tr></table></figure>

<p>42、asynio是什么？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">asyncio是并发的一种方式，是一个协程相关的库。也叫异步IO</span><br></pre></td></tr></table></figure>

<p>43、gevent模块是什么？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">gevent是一个pythn网络框架，它为各种并发和网络相关的任务提供了整洁的API</span><br></pre></td></tr></table></figure>

<p>44、 什么是twisted框架？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">twisted是用python实现的基于事件驱动的网络引擎框架</span><br></pre></td></tr></table></figure>

<p>45、什么是LVS？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">LVS是linux虚拟服务器，是一个虚拟的linux集群系统</span><br></pre></td></tr></table></figure>

<p>46、 什么是Nginx？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">nginx是一个高性能的HTTP和反向代理服务，也是一个IMAP/POP3/SMTP服务</span><br></pre></td></tr></table></figure>

<p>47、什么是keepalived?</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Keepalived是Linux下一个轻量级别的高可用解决方案</span><br></pre></td></tr></table></figure>

<p>48、什么是haproxy？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">HAProxy是一个使用C语言编写的自由及开放源代码软件，其提供高可用性、负载均衡，以及基于TCP和HTTP的应用程序代理</span><br></pre></td></tr></table></figure>

<p>49、什么是负载均衡？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">负载均衡建立在现有网络结构之上，它提供了一种廉价有效透明的方法扩展网络设备和服务器的带宽、增加吞吐量、加强网络数据处理能力、提高网络的灵活性和可用性。</span><br><span class="line">负载均衡其意思就是分摊到多个操作单元上进行执行。</span><br></pre></td></tr></table></figure>

<p>50、什么是rpc及应用场景？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">#远程过程调用 (RPC) 是一种协议，程序可使用这种协议向网络中的另一台计算机上的程序请求服务 #1.RPC采用客户机/服务器模式。请求程序就是一个客户机，而服务提供程序就是一个服务器。 #2.首先，客户机调用进程发送一个有进程参数的调用信息到服务进程，然后等待应答信息。 #2.在服务器端，进程保持睡眠状态直到调用信息到达为止。当一个调用信息到达，服务器获得进程参数，计算结果，发送答复信息，然后等待下一个调用信息， #3.最后，客户端调用进程接收答复信息，获得进程结果，然后调用执行继续进行。</span><br></pre></td></tr></table></figure>

<p> 51、什么是反向代理和反向代理？</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">正向代理</span><br><span class="line">	正向代理类似一个跳板机，代理访问外部资源。</span><br><span class="line">	正向代理 是一个位于客户端和原始服务器(origin server)之间的服务器，为了从原始服务器取得内容，客户端向代理发送一个请求并指定目标(原始服务器)，然后代理向原始服务器转交请求并将获得的内容返回给客户端。客户端必须要进行一些特别的设置才能使用正向代理。</span><br><span class="line">正向代理作用：</span><br><span class="line">	访问原来无法访问的资源，如google</span><br><span class="line">	可以做缓存，加速访问资源</span><br><span class="line">	对客户端访问授权，上网进行认证</span><br><span class="line">	代理可以记录用户访问记录（上网行为管理），对外隐藏用户信息</span><br><span class="line">反向代理</span><br><span class="line">	反向代理（Reverse Proxy）实际运行方式是指以代理服务器来接受internet上的连接请求，然后将请求转发给内部网络上的服务器，并将从服务器上得到的结果返回给internet上请求连接的客户端，此时代理服务器对外就表现为一个服务器</span><br><span class="line">反向代理的作用：</span><br><span class="line">	保证内网的安全，可以使用反向代理提供WAF功能，阻止web攻击</span><br><span class="line">	负载均衡，通过反向代理服务器来优化网站的负载</span><br></pre></td></tr></table></figure>

<p>52、 csv文件【erotic.csv】中共存在271万多条数据，请获取其中的subscription_id，并使用线程池为每100条数据创建一个线程去处理（打印或通过爬虫去提交到某处），erotic.csv文件格式为：<br>     “subscription_id”,”erotic”,”num”<br>     “UCURGHWsDe7S-v1ufCAq9Rfw”,”5”,”1”</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="第八章-django"><a href="#第八章-django" class="headerlink" title="第八章 django"></a>第八章 django</h2><ol>
<li><p>简述http协议及常用请求头。</p>
 <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">HTTP是一个客户端终端（用户）和服务器端（网站）请求和应答的标准（TCP）</span><br><span class="line">常用的请求头：</span><br><span class="line">	- user-agent</span><br><span class="line">    - host</span><br><span class="line">    - referer</span><br><span class="line">    - cookie </span><br><span class="line">    - content-type</span><br></pre></td></tr></table></figure>
</li>
<li><p>列举常见的请求方法。</p>
</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">get、post、put、delete、head、options</span><br></pre></td></tr></table></figure>

<ol start="3">
<li>列举常见的状态码。</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">1xx消息——请求已被服务器接收，继续处理</span><br><span class="line">2xx成功——请求已成功被服务器接收、理解、并接受</span><br><span class="line">3xx重定向——需要后续操作才能完成这一请求</span><br><span class="line">4xx请求错误——请求含有词法错误或者无法被执行</span><br><span class="line">5xx服务器错误——服务器在处理某个正确请求时发生错误</span><br></pre></td></tr></table></figure>

<ol start="4">
<li>简述websocket协议及实现原理。</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">websocket：</span><br><span class="line">	是给浏览器新建的一套（类似与http）协议，协议规定：（\r\n分割）浏览器和服务器连接之后不断开，以此完成：服务端向客户端主动推送消息。</span><br><span class="line">	本质：创建一个连接后不断开的socket</span><br><span class="line">实现原理：</span><br><span class="line"></span><br><span class="line">    当连接成功之后：</span><br><span class="line">        客户端（浏览器）会自动向服务端发送消息，包含： Sec-WebSocket-Key: iyRe1KMHi4S4QXzcoboMmw==</span><br><span class="line">        服务端接收之后，会对于该数据进行加密：base64(sha1(swk + magic_string))</span><br><span class="line">        构造响应头：</span><br><span class="line">                HTTP/<span class="number">1.1</span> <span class="number">101</span> Switching Protocols\r\n</span><br><span class="line">                Upgrade:websocket\r\n</span><br><span class="line">                Connection: Upgrade\r\n</span><br><span class="line">                Sec-WebSocket-Accept: 加密后的值\r\n</span><br><span class="line">                WebSocket-Location: ws://<span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span>:<span class="number">8002</span>\r\n\r\n        </span><br><span class="line">        发给客户端（浏览器）</span><br><span class="line">    建立：双工通道，接下来就可以进行收发数据</span><br><span class="line">        发送数据是加密，解密，根据payload_len的值进行处理</span><br><span class="line">            payload_len &lt;= <span class="number">125</span></span><br><span class="line">            payload_len == <span class="number">126</span></span><br><span class="line">            payload_len == <span class="number">127</span></span><br><span class="line">        获取内容：</span><br><span class="line">            mask_key</span><br><span class="line">            数据</span><br><span class="line">            根据mask_key和数据进行位运算，就可以把值解析出来。</span><br></pre></td></tr></table></figure>

<ol start="5">
<li>django中如何实现websocket？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">django中可以通过channel实现websocket</span><br></pre></td></tr></table></figure>

<ol start="6">
<li>Python web开发中, 跨域问题的解决思路是?</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ol start="7">
<li>请简述http缓存机制。</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ol start="8">
<li>谈谈你所知道的Python web框架。</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">django/flask/tornado</span><br></pre></td></tr></table></figure>

<ol start="9">
<li>Http和Https的区别？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">#Http: 80端口</span><br><span class="line">#https: 443端口</span><br><span class="line"># http信息是明文传输，https则是具有安全性的ssl加密传输协议。</span><br><span class="line">#- 自定义证书 </span><br><span class="line">    - 服务端：创建一对证书</span><br><span class="line">    - 客户端：必须携带证书</span><br><span class="line">#- 购买证书</span><br><span class="line">    - 服务端： 创建一对证书，。。。。</span><br><span class="line">    - 客户端： 去机构获取证书，数据加密后发给咱们的服务单</span><br><span class="line">    - 证书机构:公钥给改机构</span><br></pre></td></tr></table></figure>

<ol start="10">
<li>django、flask、tornado框架的比较？</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">django</span><br><span class="line">	大而全的框架它的内部组件比较多，内部提供：ORM、Admin、中间件、Form、ModelForm、Session、缓存、信号、CSRF；功能也都挺完善的</span><br><span class="line"></span><br><span class="line">flask</span><br><span class="line">	微型框架，内部组件就比较少了，但是有很多第三方组件来扩展它，</span><br><span class="line">　　比如说有那个wtform（与django的modelform类似，表单验证）、flask-sqlalchemy（操作数据库的）、</span><br><span class="line">　　flask-session、flask-migrate、flask-script、blinker可扩展强，第三方组件丰富。所以对他本身来说有那种短小精悍的感觉</span><br><span class="line">    </span><br><span class="line">	django和flask的共同点就是，他们<span class="number">2</span>个框架都没有写socket，所以他们都是利用第三方模块wsgi。但是内部使用的wsgi也是有些不同的：django本身运行起来使用wsgiref，而flask使用werkzeug wsgi还有一个区别就是他们的请求管理不太一样：django是通过将请求封装成request对象，再通过参数传递，而flask是通过上下文管理机制</span><br><span class="line"></span><br><span class="line">Tornado</span><br><span class="line"></span><br><span class="line">	是一个轻量级的Web框架，异步非阻塞+内置WebSocket功能。</span><br><span class="line">   <span class="string">'目标'</span>：通过一个线程处理N个并发请求(处理IO)。</span><br><span class="line">   <span class="string">'内部组件#内部自己实现socket</span></span><br><span class="line"><span class="string">    #路由系统</span></span><br><span class="line"><span class="string">    #视图</span></span><br><span class="line"><span class="string">  	#模板</span></span><br><span class="line"><span class="string">　　	 #cookie</span></span><br><span class="line"><span class="string">   	 #csrf</span></span><br></pre></td></tr></table></figure>

<ol start="11">
<li>什么是wsgi？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">是web服务网关接口，是一套协议。</span><br><span class="line">是通过以下模块实现了wsgi协议：</span><br><span class="line">    - wsgiref</span><br><span class="line">    - werkzurg</span><br><span class="line">    - uwsgi   关于部署</span><br><span class="line">以上模块本质：编写socket服务端，用于监听请求，当有请求到来，则将请求数据进行封装，然后交给web框架处理。</span><br></pre></td></tr></table></figure>

<ol start="12">
<li>列举django的内置组件？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">form组件：</span><br><span class="line">	对用户的请求的数据进行校验</span><br><span class="line">	生成html标签</span><br><span class="line">信号：</span><br><span class="line">	django的信号其实就是django内部为开发者预留的一些自定制功能的钩子。</span><br><span class="line">	只要在某个信号中注册了函数，那么django内部执行的过程中就会自动触发注册在信号中的函数。</span><br><span class="line">csrf：</span><br><span class="line">    目标：防止用户直接向服务端发起POST请求。</span><br><span class="line">    对所有的post请求做验证/ 将jango生成的一串字符串发送给我们，一种是从请求体发过来，一种是放在隐藏的标签里面用的是process_view　</span><br><span class="line">    方案：先发送GET请求时，将token保存到：cookie、Form表单中（隐藏的input标签），</span><br><span class="line">    以后再发送请求时只要携带过来即可。</span><br><span class="line">ContentType</span><br><span class="line">	contenttype是django的一个组件（app），</span><br><span class="line">	为我们找到django程序中所有app中的所有表并添加到记录中。</span><br><span class="line">	 可以使用他再加上表中的两个字段实现：一张表和N张表创建FK关系。 - 字段：表名称 - 字段：数据行ID </span><br><span class="line"></span><br><span class="line">session</span><br><span class="line"></span><br><span class="line">中间件：</span><br></pre></td></tr></table></figure>

<ol start="13">
<li>简述django下的(內建的)缓存机制</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ol start="14">
<li>django中model的SlugField类型字段有什么用途</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ol start="15">
<li>django中想要验证表单提交是否格式正确需要用到form中的那个方法</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p> A.  form.save()<br> B.  form.save(commit=False)<br> C.  form.verify()<br> D.  form.is_valid()</p>
<ol start="16">
<li>django常见的线上部署方式有哪几种？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ol start="17">
<li>django对数据查询结果排序怎么做, 降序怎么做？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ol start="18">
<li>下面关于http协议中的get和post方式的区别, 那些是错误的?(多选)</li>
</ol>
<p>​      A.  他们都可以被收藏, 以及缓存<br> B.  get请求参数放在url中<br> C.  get只用于查询请求, 不能用于数据请求<br> D.  get不应该处理敏感数据的请求</p>
<ol start="19">
<li>django中使用memcached作为缓存的具体方法? 优缺点说明?</li>
</ol>
<ol start="20">
<li>django的orm中如何查询 id 不等于5的元素？</li>
</ol>
<ol start="21">
<li>使用Django中model filter条件过滤方法,把下边sql语句转化成python代码</li>
</ol>
<p>​                                                  </p>
<ol start="22">
<li>从输入<a href="http://www.baidu.com/到页面返回" target="_blank" rel="noopener">http://www.baidu.com/到页面返回</a>, 中间都是发生了什么？</li>
</ol>
<ol start="23">
<li>django请求的生命周期？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">当用户在浏览器中输入url时,浏览器会生成请求头和请求体发给服务端 请求头和请求体中会包含浏览器的动作(action),这个动作通常为get或者post,体现在url之中.</span><br><span class="line">url经过Django中的wsgi,再经过Django的中间件,最后url到过路由映射表,在路由中一条一条进行匹配, 一旦其中一条匹配成功就执行对应的视图函数,后面的路由就不再继续匹配了.</span><br><span class="line">视图函数根据客户端的请求查询相应的数据.返回给Django,然后Django把客户端想要的数据做为一个字符串返回给客户端.</span><br><span class="line">客户端浏览器接收到返回的数据,经过渲染后显示给用户.</span><br></pre></td></tr></table></figure>

<ol start="24">
<li>django中如何在model保存前做一定的固定操作,比如写一句日志？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ol start="25">
<li>简述django中间件及其应用场景？</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">process_request : 请求进来时,权限认证</span><br><span class="line">process_view : 路由匹配之后,能够得到视图函数</span><br><span class="line">process_exception : 异常时执行</span><br><span class="line">process_template_responseprocess : 模板渲染时执行</span><br><span class="line">process_response : 请求有响应时执行</span><br></pre></td></tr></table></figure>

<ol start="26">
<li>简述django FBV和CBV？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">FBV和CBV本质是一样的，基于函数的视图叫做FBV，基于类的视图叫做CBV 在python中使用CBV的优点：</span><br><span class="line">.提高了代码的复用性，可以使用面向对象的技术，比如Mixin（多继承）</span><br><span class="line">.可以用不同的函数针对不同的HTTP方法处理，而不是通过很多if判断，提高代码可读性</span><br></pre></td></tr></table></figure>

<ol start="27">
<li>如何给django CBV的函数设置添加装饰器？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">from django.utils.decorators import method_decorator</span><br><span class="line"># 1、给方法加：</span><br><span class="line">@method_decorator(check_login)</span><br><span class="line">def post(self, request):</span><br><span class="line">	...</span><br><span class="line"># 2、给dispatch加：</span><br><span class="line">@method_decorator(check_login)</span><br><span class="line">def dispatch(self, request, *args, **kwargs):</span><br><span class="line">	...</span><br><span class="line"># 3、给类加：</span><br><span class="line">@method_decorator(check_login, name=&quot;get&quot;)</span><br><span class="line">@method_decorator(check_login, name=&quot;post&quot;)</span><br><span class="line">class HomeView(View):</span><br></pre></td></tr></table></figure>

<ol start="28">
<li>django如何连接多个数据库并实现读写分离？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">在配置文件中添加slave数据库配置</span><br><span class="line">创建数据库操作的路由分发类</span><br><span class="line">配置读写分离路由</span><br><span class="line">连接：https://blog.csdn.net/linzi1994/article/details/82934612</span><br></pre></td></tr></table></figure>

<ol start="29">
<li>列举django orm 中你了解的所有方法？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">&lt;1&gt; all():                  查询所有结果 </span><br><span class="line">&lt;2&gt; filter(**kwargs):       它包含了与所给筛选条件相匹配的对象。获取不到返回None</span><br><span class="line">&lt;3&gt; get(**kwargs):          返回与所给筛选条件相匹配的对象，返回结果有且只有一个。</span><br><span class="line">                            如果符合筛选条件的对象超过一个或者没有都会抛出错误。</span><br><span class="line">&lt;4&gt; exclude(**kwargs):      它包含了与所给筛选条件不匹配的对象</span><br><span class="line">&lt;5&gt; order_by(*field):       对查询结果排序</span><br><span class="line">&lt;6&gt; reverse():              对查询结果反向排序 </span><br><span class="line">&lt;8&gt; count():                返回数据库中匹配查询(QuerySet)的对象数量。 </span><br><span class="line">&lt;9&gt; first():                返回第一条记录 </span><br><span class="line">&lt;10&gt; last():                返回最后一条记录 </span><br><span class="line">&lt;11&gt; exists():              如果QuerySet包含数据，就返回True，否则返回False</span><br><span class="line">&lt;12&gt; values(*field):        返回一个ValueQuerySet——一个特殊的QuerySet，运行后得到的</span><br><span class="line">                            并不是一系 model的实例化对象，而是一个可迭代的字典序列</span><br><span class="line">&lt;13&gt; values_list(*field):   它与values()非常相似，它返回的是一个元组序列，values返回的是一个字典序列</span><br><span class="line">&lt;14&gt; distinct():            从返回结果中剔除重复纪录</span><br></pre></td></tr></table></figure>

<ol start="30">
<li>django中的F的作用？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">比较两个字段</span><br><span class="line">对一个字段进行批量处理</span><br></pre></td></tr></table></figure>

<ol start="31">
<li>django中的Q的作用？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">F查询：对数据本身的不同字段进行操作 如:比较和更新</span><br><span class="line">Q查询：对对象进行复杂查询，并支持and，or，not等操作符</span><br></pre></td></tr></table></figure>

<ol start="32">
<li>django中如何执行原生SQL？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">1.使用execute执行自定义的SQL</span><br><span class="line">     直接执行SQL语句（类似于pymysql的用法）</span><br><span class="line">        # 更高灵活度的方式执行原生SQL语句</span><br><span class="line">        from django.db import connection</span><br><span class="line">        cursor = connection.cursor()</span><br><span class="line">        cursor.execute(&quot;SELECT DATE_FORMAT(create_time, &apos;%Y-%m&apos;) FROM blog_article;&quot;)</span><br><span class="line">        ret = cursor.fetchall()</span><br><span class="line">        print(ret)</span><br><span class="line">2.使用extra方法 ：queryset.extra(select=&#123;&quot;key&quot;: &quot;原生的SQL语句&quot;&#125;)</span><br><span class="line">3.使用raw方法</span><br><span class="line">    1.执行原始sql并返回模型</span><br><span class="line">    2.依赖model多用于查询</span><br></pre></td></tr></table></figure>

<ol start="33">
<li>only和defer的区别？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">defer--&gt; 除了指定字段之外</span><br><span class="line">only--&gt; 只查询几个字段</span><br><span class="line">	比如：ret=Book.object.all().only(&apos;name&apos;)</span><br><span class="line">	id始终会查，结果是queryset对象,套book对象(里面只有id与name字段)</span><br><span class="line">	如果取price，会发生什么？他会再次查询数据库，对数据库造成压力</span><br></pre></td></tr></table></figure>

<ol start="34">
<li>select<em>related*</em>和prefetch*related的区别？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">前提：有外键存在时，可以很好的减少数据库请求的次数,提高性能 select_related通过多表join关联查询,一次性获得所有数据,只执行一次SQL查询 prefetch_related分别查询每个表,然后根据它们之间的关系进行处理,执行两次查询</span><br></pre></td></tr></table></figure>

<ol start="35">
<li>django中filter和exclude的区别</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">def filter(self, *args, **kwargs)</span><br><span class="line">    # 条件查询(符合条件)</span><br><span class="line">    # 查出符合条件</span><br><span class="line">    # 条件可以是：参数，字典，Q</span><br><span class="line"></span><br><span class="line">def exclude(self, *args, **kwargs)</span><br><span class="line">    # 条件查询(排除条件)</span><br><span class="line">    # 排除不想要的</span><br><span class="line">    # 条件可以是：参数，字典，Q</span><br></pre></td></tr></table></figure>

<ol start="36">
<li>django中values和values_list的区别？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">values : queryset类型的列表中是字典</span><br><span class="line">values_list : queryset类型的列表中是元组</span><br></pre></td></tr></table></figure>

<ol start="37">
<li>如何使用django orm批量创建数据？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">objs=[models.Book(title=&quot;图书&#123;&#125;&quot;.format(i+15)) for i in range(100)]</span><br><span class="line">models.Book.objects.bulk_create(objs)</span><br></pre></td></tr></table></figure>

<ol start="38">
<li>django的Form和ModeForm的作用？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Form作用： 1.在前端生成HTML代码 2.对数据作有效性校验 3.返回校验信息并展示</span><br><span class="line">ModeForm：根据模型类生成From组件,并且可以操作数据库</span><br></pre></td></tr></table></figure>

<ol start="39">
<li>django的Form组件中，如果字段中包含choices参数，请使用两种方式实现数据源实时更新。</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"># 1. 重写构造函数</span><br><span class="line">def__init__(self, *args, **kwargs):</span><br><span class="line">     super().__init__(*args, **kwargs)</span><br><span class="line">     self.fields[&quot;city&quot;].widget.choices = models.City.objects.all().values_list(&quot;id&quot;, &quot;name&quot;)</span><br><span class="line"></span><br><span class="line"># 2. 利用ModelChoiceField字段，参数为queryset对象</span><br><span class="line">authors=form_model.ModelMultipleChoiceField(queryset=models.NNewType.objects.all())</span><br></pre></td></tr></table></figure>

<ol start="40">
<li>django的Model中的ForeignKey字段中的on_delete参数有什么作用？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">删除关联表中的数据时,当前表与其关联的field的操作</span><br><span class="line">django2.0之后，表与表之间关联的时候,必须要写on_delete参数,否则会报异常</span><br></pre></td></tr></table></figure>

<ol start="41">
<li>django中csrf的实现机制？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">1、django第一次响应来自某个客户端的请求时,后端随机产生一个token值，把这个token保存在SESSION状态中;同时,后端把这个token放到cookie中交给前端页面；</span><br><span class="line">2、下次前端需要发起请求（比如发帖）的时候把这个token值加入到请求数据或者头信息中,一起传给后端；Cookies:&#123;csrftoken:xxxxx&#125;</span><br><span class="line">3、后端校验前端请求带过来的token和SESSION里的token是否一致。</span><br></pre></td></tr></table></figure>

<ol start="42">
<li>django如何实现websocket？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ol start="43">
<li>基于django使用ajax发送post请求时，有哪种方法携带csrf token？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">1.后端将csrftoken传到前端，发送post请求时携带这个值发送</span><br><span class="line">data: &#123;</span><br><span class="line">        csrfmiddlewaretoken: &apos;&#123;&#123; csrf_token &#125;&#125;&apos;</span><br><span class="line">  &#125;,</span><br><span class="line"></span><br><span class="line">2.获取form中隐藏标签的csrftoken值，加入到请求数据中传给后端</span><br><span class="line">data: &#123;</span><br><span class="line">          csrfmiddlewaretoken:$(&apos;[name=&quot;csrfmiddlewaretoken&quot;]&apos;).val()</span><br><span class="line">     &#125;,</span><br><span class="line"></span><br><span class="line">3.cookie中存在csrftoken,将csrftoken值放到请求头中</span><br><span class="line">headers:&#123; &quot;X-CSRFtoken&quot;:$.cookie(&quot;csrftoken&quot;)&#125;</span><br></pre></td></tr></table></figure>

<ol start="44">
<li>django缓存如何设置？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ol start="45">
<li>django的缓存能使用redis吗？如果可以的话，如何配置？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ol start="46">
<li>django路由系统中name的作用？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">用于反向解析路由，相当于给url取个别名，只要这个名字不变，即使对应的url改变</span><br><span class="line">通过改名字也能找到该条url</span><br></pre></td></tr></table></figure>

<ol start="47">
<li>django的模板中filter、simple<em>tag*</em>、inclusion*tag的区别？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">自定义filter：&#123;&#123; 参数1|filter函数名:参数2 &#125;&#125; 1.可以与if标签来连用 2.自定义时需要写两个形参</span><br><span class="line">    例子：自定义filter</span><br><span class="line">            1. 在app01下创建一个叫templatetags的Python包</span><br><span class="line">            2. 在templatetags的文件夹下创建py文件  myfilters</span><br><span class="line">            3. 在py文件中写代码</span><br><span class="line">                from django import template</span><br><span class="line">                register = template.Library()</span><br><span class="line">                </span><br><span class="line">                @register.filter</span><br><span class="line">                def add_sb(value,arg=&apos;aaa&apos;):</span><br><span class="line">                    return &quot;&#123;&#125;_sb_&#123;&#125;&quot;.formart(value,arg)</span><br><span class="line">                    </span><br><span class="line">                @register.filter(name=&apos;sb&apos;)</span><br><span class="line">                def add_sb(value,arg=&apos;aaa&apos;):</span><br><span class="line">                    return &quot;&#123;&#125;_sb_&#123;&#125;&quot;.formart(value,arg)     </span><br><span class="line">            4. 使用自定义filter</span><br><span class="line">                &#123;% load myfilters %&#125;</span><br><span class="line">                &#123;&#123; name|add_sb:&apos;xxx&apos;&#125;&#125;</span><br><span class="line">                &#123;&#123; name|sb:&apos;xxx&apos;&#125;&#125;</span><br><span class="line">simple_tag:&#123;% simple_tag函数名 参数1 参数2 %&#125; 1.可以传多个参数,没有限制 2.不能与if标签来连用</span><br><span class="line">例子：自定义simpletag</span><br><span class="line">    创建</span><br><span class="line">        1 、在app01中创建一个名字是templatetags的包，</span><br><span class="line">        2、在包中创建一个py文件</span><br><span class="line">        3、在py文件中导入</span><br><span class="line">              from django import template</span><br><span class="line">              register = template.Library()</span><br><span class="line">        4、写函数</span><br><span class="line">              @register.simple_tag(name=&quot;plus&quot;)</span><br><span class="line">              def plus(a,b,c):</span><br><span class="line">                  return &apos;&#123;&#125;+&#123;&#125;+&#123;&#125;&apos;.format(a,b,c)</span><br><span class="line">        5、加装饰器@register.simple_tag(name=&quot;plus&quot;)</span><br><span class="line">  使用</span><br><span class="line">      1、导入</span><br><span class="line">            &#123;% load mytag %&#125;</span><br><span class="line">      2、使用</span><br><span class="line">           &#123;% plus 1 2 3 %&#125;</span><br></pre></td></tr></table></figure>

<ol start="48">
<li>django-debug-toolbar的作用？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">是django的第三方工具包，给django扩展了调试功能，包括查看sql语句，db查询次数，request，headers等</span><br></pre></td></tr></table></figure>

<ol start="49">
<li>django中如何实现单元测试？</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">对于每一个测试方法都会将setUp()和tearDown()方法执行一遍</span><br><span class="line">会单独新建一个测试数据库来进行数据库的操作方面的测试，默认在测试完成后销毁。</span><br><span class="line">在测试方法中对数据库进行增删操作，最后都会被清除。也就是说，在test_add中插入的数据，在test_add测试结束后插入的数据会被清除。</span><br><span class="line">django单元测试时为了模拟生产环境，会修改settings中的变量，例如, 把DEBUG变量修改为<span class="literal">True</span>, 把ALLOWED_HOSTS修改为[*]。</span><br></pre></td></tr></table></figure>

<ol start="50">
<li>解释orm中 db first 和 code first的含义？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">db first: 先创建数据库，再更新表模型</span><br><span class="line">code first：先写表模型，再更新数据库</span><br></pre></td></tr></table></figure>

<ol start="51">
<li>django中如何根据数据库表生成model类？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">1、修改seting文件，在setting里面设置要连接的数据库类型和名称、地址</span><br><span class="line">2、运行下面代码可以自动生成models模型文件</span><br><span class="line">       - python manage.py inspectdb</span><br><span class="line">3、创建一个app执行下下面代码：</span><br><span class="line">       - python manage.py inspectdb &gt; app/models.py</span><br></pre></td></tr></table></figure>

<ol start="52">
<li>使用orm和原生sql的优缺点？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">SQL：</span><br><span class="line"># 优点：</span><br><span class="line">执行速度快</span><br><span class="line"># 缺点：</span><br><span class="line">编写复杂，开发效率不高</span><br><span class="line">---------------------------------------------------------------------------</span><br><span class="line">ORM：</span><br><span class="line"># 优点：</span><br><span class="line">让用户不再写SQL语句，提高开发效率,更换数据库时，不需要重写每一条sql语句</span><br><span class="line">可以很方便地引入数据缓存之类的附加功能</span><br><span class="line"># 缺点：</span><br><span class="line">在处理多表联查、where条件复杂查询时，ORM的语法会变得复杂。</span><br><span class="line">没有原生SQL速度快</span><br></pre></td></tr></table></figure>

<ol start="53">
<li>简述MVC和MTV</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">MVC：model、view(模块)、controller(视图)</span><br><span class="line">MTV：model、tempalte、view</span><br></pre></td></tr></table></figure>

<ol start="54">
<li>django的contenttype组件的作用？</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">contenttype是django的一个组件(app)，它可以将django下所有app下的表记录下来</span><br><span class="line">可以使用他再加上表中的两个字段,实现一张表和N张表动态创建FK关系。</span><br><span class="line">   - 字段：表名称</span><br><span class="line">   - 字段：数据行ID</span><br></pre></td></tr></table></figure>

<p>55、django如何实现单元测试</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">django的单元测试使用python的unittest模块，这个模块使用基于类的方法来定义测试。类名为django.test</span><br><span class="line">#链接：https://www.tuicool.com/articles/YRra6zB</span><br></pre></td></tr></table></figure>


      
    </div>
    
    
    

    

    

    
      <div>
        <ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者：</strong>
    
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="http://yoursite.com/2019/09/20/【面试题】01-2绿皮书二/" title="绿皮书02">http://yoursite.com/2019/09/20/【面试题】01-2绿皮书二/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>
    本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 3.0</a> 许可协议。转载请注明出处！
  </li>
</ul>

      </div>
    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/dxl/tags/面试题/" rel="tag"># 面试题</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/dxl/2019/09/20/【面试题】01-1绿皮书一/" rel="next" title="绿皮书01">
                <i class="fa fa-chevron-left"></i> 绿皮书01
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/dxl/2019/09/20/【面试题】01-3绿皮书 数据库/" rel="prev" title="绿皮书数据库">
                绿皮书数据库 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/dxl/images/avatar.png" alt>
            
              <p class="site-author-name" itemprop="name"></p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/dxl/archives">
              
                  <span class="site-state-item-count">43</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/dxl/categories/index.html">
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/dxl/tags/index.html">
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-inline">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-sign-out"></i>
                我的友链
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="tencent://message/?Menu=yes&uin=1258517737&Site=QQ%E6%9E%81%E5%AE%A2&Service=300&sigT=45a1e5847943b64c6ff3990f8a9e644d2b31356cb0b4ac6b24663a3c8dd0f8aa12a595b1714f9d45/" title="申请坑位" target="_blank">申请坑位</a>
                  </li>
                
              </ul>
            </div>
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#第五章"><span class="nav-number">1.</span> <span class="nav-text">第五章</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第八章-django"><span class="nav-number">2.</span> <span class="nav-text">第八章 django</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      
        <div class="back-to-top">
          <i class="fa fa-arrow-up"></i>
          
            <span id="scrollpercent"><span>0</span>%</span>
          
        </div>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-hand-peace-o"></i>
  </span>
  <span class="author" itemprop="copyrightHolder"></span>

  
</div>









        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      本站访客数
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人次
    </span>
  

  
    <span class="site-pv">
      本站总访问量
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>








        
      </div>
    </footer>

    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/dxl/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/dxl/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/dxl/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/dxl/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/dxl/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/dxl/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/dxl/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/dxl/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/dxl/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/dxl/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/dxl/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/dxl/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/dxl/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  










  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: false,
        notify: false,
        appId: '13B0JGDuA6ttduN8AQaR8CzF-gzGzoHsz',
        appKey: 'I13r9r5mVgq4jQYpYy6V4gW3',
        placeholder: '欢迎大佬指点~~~',
        avatar:'mm',
        guest_info:guest,
        pageSize:'10' || 10,
    });
  </script>



  





  

  

  

  
  

  

  

  

</body>
</html>
